import type { Metadata } from 'next'; import Link from 'next/link'; import { notFound } from 'next/navigation'; import { ExternalLink } from 'lucide-react'; import { PageHeader, Section, KV, Note } from '@/components/ui/section'; import { Badge, StatusBadge } from '@/components/ui/badge'; import { EmptyState } from '@/components/ui/empty-state'; import { Freshness } from '@/components/ui/freshness'; import { getSourceBySlug, listRuns, recordCountsByKind, licenseMeaning, sourceDomains } from '@/lib/queries/sources'; import { fmtDate, fmtDateTime, fmtDuration, fmtInt, humanize, relativeTime } from '@/lib/format'; export const revalidate = 300; export async function generateMetadata({ params }: { params: Promise<{ slug: string }> }): Promise { const s = await getSourceBySlug((await params).slug); return s ? { title: `${s.name} — source`, description: s.description ?? `License, access, connector health and record counts for ${s.name}.` } : { title: 'Source' }; } export default async function SourcePage({ params }: { params: Promise<{ slug: string }> }) { const { slug } = await params; const s = await getSourceBySlug(slug); if (!s) notFound(); const [runs, kinds] = await Promise.all([listRuns({ sourceId: s.id, limit: 30 }), recordCountsByKind(s.id)]); const domains = [...sourceDomains(s)]; return (

{s.id} connector: {s.slug} {s.homepage ? ( Homepage ) : null} {s.docs_url ? ( API docs ) : null} {s.terms_url ? ( Terms ) : null}

{s.license_status} }, { k: 'License', v: s.license ?? not recorded }, { k: 'Commercial use', v: humanize(s.commercial_use) }, { k: 'Redistribution', v: humanize(s.redistribution) }, { k: 'Reviewed', v: s.license_reviewed_at ? fmtDate(s.license_reviewed_at) : not yet reviewed }, { k: 'Approved for production', v: s.approved_for_production ? 'Yes' : 'No' }, { k: 'Attribution', v: s.attribution ? {s.attribution} : — }, ]} /> {licenseMeaning(s.license_status, s.redistribution, s.commercial_use)}
{runs.length ? (
{runs.map((r) => ( ))}
Run Mode Status Started Duration Fetched Created Updated Rejected HTTP fail Dataset version
{r.id} {r.anomaly ? anomaly : null} {r.schema_drift?.length ? drift {r.schema_drift.length} : null} {r.mode} {fmtDateTime(r.started_at)} {fmtDuration(r.duration_ms)} {fmtInt(r.records_fetched)} {fmtInt(r.records_created)} {fmtInt(r.records_updated)} {fmtInt(r.records_rejected)} {fmtInt(r.http_failures)}/{fmtInt(r.http_requests)} {r.dataset_version ?? '—'}
) : ( {s.status === 'awaiting_credentials' ? 'The connector is waiting for API credentials.' : s.status === 'review' ? 'The connector is blocked until the license review completes.' : 'This connector has not been executed on this environment.'} )}
{kinds.length ? (
{kinds.map((k) => ( ))}
Entity kind Status Records (count) Last retrieved
{k.entity_kind} {fmtInt(k.n)} {k.last_retrieved ? fmtDateTime(k.last_retrieved) : '—'}
) : ( No record ingested from this source yet. )}
); }